﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace GMS.Utils
{
    public class PagedListNew<T> : List<T>
    {
        public int Total { get; set; }

        public int PageSize { get; set; }

        public int CurrentPage { get; set; }

        public int PageTotal { get; set; }

        public PagedListNew(List<T> items, int count, int pageNumber, int pageSize)
        {
            Total = count;
            PageSize = pageSize;
            CurrentPage = pageNumber;
            PageTotal = (int)Math.Ceiling(count / (double)pageSize);
            AddRange(items);
        }

        public static async Task<PagedListNew<T>> CreateAsync(List<T> data, int total, int pageNumber, int pageSize)
        {
            var count = total;
            var items = data;
            return await Task.FromResult(new PagedListNew<T>(items, count, pageNumber, pageSize));
        }

    }
}